<?php
include_once 'ZCollection.php';
class ZSmtCollection extends ZCollection {
    public static $smt = Array(
        0, 'Forum', 'New', 'Blog', 'Facebook', 'Twitter', 'Youtube', 'Ads'
    );

    public function __construct() {
        for($i = 1; $i < count(self::$smt); $i++) {
            $this->items[$i] = new ZSmtItem($i);
        }
    }

    /**
     * Get number of smt
     * @return int Number of messages
     */
    public function count(){
        return count($this->items);
    }

    /**
     * Get Smt Item Index
     * @param $index
     * @return ZSmtItem
     */
    public function getIndex($index){
        return $this->items[$index];
    }

    /**
     * Add a message
     * @param $item ZSmtItem
     */
    public function addItem($item){
        $this->items[$item->getId()] = $item;
    }

    /**
     * Get array of items
     * @return ZSmtItem[]
     */
    public function getItems() {
        return $this->items;
    }

    /**
     * Get array with number of posts of SMT
     * @return array
     */
    public function getPosts(){

        foreach($this->getItems() as $value){
            $arr[] = array($value->getName(), (int) $value->getNumberOfPosts());
        }
        return $arr;
    }

    /**
     * Get array with number of authors of SMT
     * @return array
     */
    public function getAuthors(){
        foreach($this->getItems() as $value){
            $arr[] = array($value->getName(), (int) $value->getNumberOfAuthors());
        }
        return $arr;
    }

    /**
     * Get array with number of threads of SMT
     * @return array
     */
    public function getThreads(){
        foreach($this->getItems() as $value){
            $arr[] = array($value->getName(), (int) $value->getNumberOfThreads());
        }
        return $arr;
    }
}